<HTML><HEAD><TITLE>member(?Term, ?List)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(lists)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>member(?Term, ?List)</H1>
Succeeds if Term unifies with a member of the list List.


<DL>
<DT><EM>?Term</EM></DT>
<DD>Prolog term.
</DD>
<DT><EM>?List</EM></DT>
<DD>List or variable.
</DD>
</DL>
<H2>Description</H2>
   Tries to unify Term with an element of the list List.
<P>
   If Term is a variable and List is a list, all the members of the list
   List are found on backtracking.
<P>
   If List is not instantiated, member/2 binds List to a new partial list
   containing the element Term.
<P>
   The definition of this Prolog library predicate is:
<PRE>
       member(X,[X|_]).
       member(X,[Y|T]) :- member(X,T).
</PRE>
   This predicate does not perform any type testing functions.
	
<H3>Modes and Determinism</H3><UL>
<LI>member(-, +) is nondet
<LI>member(+, -) is nondet
<LI>member(-, -) is multi
</UL>
<H3>Fail Conditions</H3>
   Fails if Term does not unify with a member of the list List.


<H3>Resatisfiable</H3>
   Yes.
<H2>Examples</H2>
<PRE>
Success:
      member(q,[1,2,3,p,q,r]).
      member(q,[1,2,F]).      (gives F=q).
      member(X,[1,X]).        (gives X=1; X=_g118).
      member(X,[2,I]).        (gives X=2 I=_g114; X=_g94 I=_g94).
      member(1,L).            (gives L=[1|_g64];
                                     L=[_g62,1|_g68] etc).

Fail:
      member(4,[1,2,3]).



</PRE>
<H2>See Also</H2>
<A HREF="../../lib/lists/memberchk-2.html">memberchk / 2</A>
</BODY></HTML>
